//
//  MvTableViewCell.m
//  海角音乐
//
//  Created by dllo on 15/8/17.
//  Copyright (c) 2015年 杨元石. All rights reserved.
//

#import "MvTableViewCell.h"
#import "DEFINE.h"
@implementation MvTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        CGFloat title_X = SCREEN_WIDTH*0.0266667; // 10
        CGFloat title_width = SCREEN_WIDTH*0.106667; // 40
        CGFloat title_height = SCREEN_WIDTH*0.08; // 30
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(title_X, 2, title_width, title_height)];
        _title.font = [UIFont boldSystemFontOfSize:22];
        _title.textColor = [UIColor colorWithRed:69/255. green:160/255. blue:254/255. alpha:1.0];
        _title.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_title];
        [_title release];
        
        UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(title_X, title_height+1, title_width, 2)];
        line.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:line];
        [line release];
        
        _time = [[UILabel alloc] initWithFrame:CGRectMake(title_X, title_height+3, title_width, title_height)];
        _time.font = [UIFont boldSystemFontOfSize:14];
        _time.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_time];
        [_time release];
        
        
        
        CGFloat desc_X = SCREEN_WIDTH*0.146666; // 55
        CGFloat desc_width = SCREEN_WIDTH*0.186666; // 70
        
        
        _desc = [[UILabel alloc] initWithFrame:CGRectMake(desc_X, 2, SCREEN_WIDTH-desc_width, title_width)];
        _desc.font = [UIFont systemFontOfSize:14];
        _desc.numberOfLines = 0;
        [self.contentView addSubview:_desc];
        [_desc release];
        
        
        CGFloat big_Y = SCREEN_WIDTH*0.1733333; // 65
        CGFloat big_height = SCREEN_WIDTH*0.48; // 180
        
        
        _bigPicUrl = [[UIImageView alloc] initWithFrame:CGRectMake(title_X, big_Y, SCREEN_WIDTH-20, big_height)];
        _bigPicUrl.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_bigPicUrl];
        [_bigPicUrl release];
        
        
        CGFloat bofang_width = SCREEN_WIDTH*0.133333; // 50
        CGFloat bofang_Y = SCREEN_WIDTH*0.3733333; // 140        
        
        _bofangImage = [[UIImageView alloc] initWithFrame:CGRectMake(_bigPicUrl.frame.size.width/2, bofang_Y, bofang_width, bofang_width)];
        _bofangImage.center = CGPointMake(_bigPicUrl.frame.size.width/2, _bigPicUrl.frame.size.height/2+60);
        _bofangImage.image = [[UIImage imageNamed:@"mv_cover_play_icon@2x.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self.contentView addSubview:_bofangImage];
        
        
    }
    return self;
}

- (void)getMvModel:(MvModel *)model
{
    
    [_bigPicUrl sd_setImageWithURL:[NSURL URLWithString:model.bigPicUrl] placeholderImage:[UIImage imageNamed:@"mv_cover_default.jpg"]];
    
    //从字符A中分隔成2个元素的数组
    NSArray *array = [model.title componentsSeparatedByString:@"/"];
    _title.text = [array objectAtIndex:0];
    _time.text = [array objectAtIndex:1];
    _desc.text = model.desc;
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
